# 构造一个基类“学生” ，包含“学习”方法。
# 构造继承类“计算机专业学生”，包含方法“编程”。
# 构造继承类“金融专业学生”，包含方法“金融交易”。
# 构造不同类的对象，对各自方法进行调用

# class Student():
#     def study(self):
#         ...
#
# class Computer(Student):
#     def coding(self):
#         ...
#
#     def study(self):
#         ...
#
#     def sleep(self):
#         print(312)
#
# class Finance(Student):
#     def ft(self):
#         ...
#
#     def study(self):
#         ...
#
#     def sleep(self):
#         print("123")
#
# c = Computer()
# f = Finance()
# # c.coding()
# # f.ft()
#
#
# def func(obj):
#     stu = Student()
#     stu.study()
#     obj.sleep()
#
# func(c)
# func(f)


class User:
    def __init__(self,name,age,sex):
        self.name = name
        self.age = age
        self.sex = sex

    def eat(self):
        print("eat")
    def sleep(self):
        print("sleep")

name = input("请输入姓名: ")
age = input("请输入年龄: ")
sex = input("请输入性别: ")

user = User(name,age,sex)

while True:
    res = input("请输入：")

    if hasattr(user, res):
        attr = getattr(user, res)
        if callable(attr):
            attr()
        else:
            print(attr)
    else:
        print("您输入的字符串查找不到，请重新输入！")